Remove Specified Item
রিমুভ() পদ্ধতি নির্দিষ্ট আইটেমকে সরিয়ে দেয়।
Example
thislist = ["apple", "banana", "cherry"]
thislist.remove("banana")
print(thislist)
যদি নির্দিষ্ট মান সহ একাধিক আইটেম থাকে, তাহলে remove() পদ্ধতিটি প্রথম উদাহরণটিকে সরিয়ে দেয়:
Example
thislist = ["apple", "banana", "cherry", "banana", "kiwi"]
thislist.remove("banana")
print(thislist)
Remove Specified Index
পপ() পদ্ধতি নির্দিষ্ট কোড মুছে দেয়।
Example
thislist = ["apple", "banana", "cherry"]
thislist.pop(1)
print(thislist)
যদি আপনি একটি সূচক নির্দিষ্ট না করেন, pop() পদ্ধতিটি শেষ আইটেমটি মুছে ফেলবে।
Example
thislist = ["apple", "banana", "cherry"]
thislist.pop()
print(thislist)
The del Keyword
del কীওয়ার্ড নির্দিষ্ট কোড মুছে দেয়:
Example
thislist = ["apple", "banana", "cherry"]
del thislist[0]
print(thislist)
del সম্পূর্ণ কীওয়ার্ড তালিকা মুছে ফেলতে পারে।
Example
thislist = ["apple", "banana", "cherry"]
del thislist
Clear the List
clear() পদ্ধতি তালিকাটি খালি করে।
তালিকাটি এখনও বিদ্যমান থাকবে, তবে এতে কোন বিষয়বস্তু থাকবে না।
Example
thislist = ["apple", "banana", "cherry"]
thislist.clear()
print(thislist)
Remove Methods Comparison
| Method | Description | Example |
|---|---|---|
| remove() | মানের উপর ভিত্তি করে আইটেম মুছে দেয় | list.remove("item") |
| pop() | সূচী অনুসারে আইটেম মুছে দেয় (অন্যথায় শেষ আইটেম) | list.pop(1) or list.pop() |
| del | সূচী দ্বারা আইটেম মুছে দেয় বা সম্পূর্ণ তালিকা মুছে দেয় | del list[0] or del list |
| clear() | তালিকাটি খালি করুন তবে তালিকাটি মুছবেন না | list.clear() |
List Removal Methods
remove()
list.remove(value)
মান অনুযায়ী আইটেম মুছে দেয়
pop()
list.pop(index)
কোড দ্বারা আইটেম সরান, ফেরত
del
del list[index]
কোড দ্বারা আইটেম মুছে দেয়, এটি ফেরত না
clear()
list.clear()
তালিকাটি খালি করুন, কিন্তু মুছে ফেলবেন না